local status, lspconfig = pcall(require, "lspconfig")
if not status then
  vim.notify("lspconfig is not found")
  return
end

local capabilities = require("cmp_nvim_lsp").default_capabilities()

lspconfig.lua_ls.setup({
  capabilities = capabilities,
  settings = {
    Lua = {
      hint = {
        enable = true,
        setType = true,
        paramType = true,
        paramName = "Enable",
        semicolon = "Enable",
        arrayIndex = "Enable",
      },
    },
  },
})

-- tsserver
local inlayHints = {
  includeInlayParameterNameHints = "all",
  includeInlayParameterNameHintsWhenArgumentMatchesName = false,
  includeInlayFunctionParameterTypeHints = true,
  includeInlayVariableTypeHints = true,
  includeInlayVariableTypeHintsWhenTypeMatchesName = false,
  includeInlayPropertyDeclarationTypeHints = true,
  includeInlayFunctionLikeReturnTypeHints = true,
  includeInlayEnumMemberValueHints = true,
}
lspconfig.tsserver.setup({
  capabilities = capabilities,
  settings = {
    typescript = {
      inlay_hint = inlayHints,
    },
    javascript = {
      inlay_hint = inlayHints,
    },
  },
})

lspconfig.gopls.setup({
  capabilities = capabilities,
  settings = {
    gopls = {
      hints = {
        rangeVariableTypes = true,
        parameterNames = true,
        constantValues = true,
        assignVariableTypes = true,
        compositeLiteralFields = true,
        compositeLiteralTypes = true,
        functionTypeParameters = true,
      },
    },
  },
})

-- clangd
require("lspconfig").clangd.setup({
  settings = {
    clangd = {
      InlayHints = {
        Designators = true,
        Enabled = true,
        ParameterNames = true,
        DeducedTypes = true,
      },
      fallbackFlags = { "-std=c++20" },
    },
  },
})

vim.lsp.inlay_hint.enable(true)
